#include "stdafx.h"
#include "IniRead.h"

IniReader& GetIniReader()
{
	static IniReader reader;
	return reader;
}

const char* IniReader::GetIniFileName(INI_TYPE eType)
{
	return strIniFileFullName[eType].c_str();
}

void IniReader::InitIniPath()
{
	char strStartPath[1024] = {0,};	
	GetCurrentDirectory(1024, strStartPath);

	char szTemp[1024];
	sprintf(szTemp, "%s\\ini\\Common.ini", strStartPath );
	strIniFileFullName[INI_TYPE_COMMON] = szTemp;
	sprintf(szTemp, "%s\\ini\\Charactor.ini", strStartPath );
	strIniFileFullName[INI_TYPE_CHARACTOR] = szTemp;
	sprintf(szTemp, "%s\\ini\\Stage_1.ini", strStartPath );
	strIniFileFullName[INI_TYPE_STAGE_1] = szTemp;	
	sprintf(szTemp, "%s\\ini\\Stage_2.ini", strStartPath );
	strIniFileFullName[INI_TYPE_STAGE_2] = szTemp;	
}

int	IniReader::GetIniKeyValue_Int(INI_TYPE eType, const char* pszSectionName, const char* pszKeyName)
{	
	return ::GetPrivateProfileInt(pszSectionName, pszKeyName, 0, GetIniFileName(eType));
}

void IniReader::GetIniKeyValue_String(INI_TYPE eType, char* pOutString, int nOutStringSize, const char* pszSectionName, const char* pszKeyName)
{	
	::GetPrivateProfileString(pszSectionName, pszKeyName, "error", pOutString, nOutStringSize, GetIniFileName(eType));
}